if ((error = __vmread(VM_EXIT_REASON, &exit_reason)))
__vmx_bug(®s);
+ perfc_incra(vmexits, exit_reason);
+
__vmread(IDT_VECTORING_INFO_FIELD, &idtv_info_field);
if (idtv_info_field & INTR_INFO_VALID_MASK) {
__vmwrite(VM_ENTRY_INTR_INFO_FIELD, idtv_info_field);
__vmx_bug(®s);
vector &= 0xff;
+ perfc_incra(cause_vector, vector);
+
switch (vector) {
#ifdef XEN_DEBUGGER
case VECTOR_DB:
#define perfc_value(x) atomic_read(&perfcounters.x[0])
#define perfc_valuec(x) atomic_read(&perfcounters.x[smp_processor_id()])
-#define perfc_valuea(x,y) atomic_read(&perfcounters.x[y])
+#define perfc_valuea(x,y) \
+ { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
+ atomic_read(&perfcounters.x[y]); }
#define perfc_set(x,v) atomic_set(&perfcounters.x[0], v)
#define perfc_setc(x,v) atomic_set(&perfcounters.x[smp_processor_id()], v)
-#define perfc_seta(x,y,v) atomic_set(&perfcounters.x[y], v)
+#define perfc_seta(x,y,v) \
+ { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
+ atomic_set(&perfcounters.x[y], v); }
#define perfc_incr(x) atomic_inc(&perfcounters.x[0])
#define perfc_decr(x) atomic_dec(&perfcounters.x[0])
#define perfc_incrc(x) atomic_inc(&perfcounters.x[smp_processor_id()])
-#define perfc_incra(x,y) atomic_inc(&perfcounters.x[y])
+#define perfc_incra(x,y) \
+ { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
+ atomic_inc(&perfcounters.x[y]); }
#define perfc_add(x,y) atomic_add((y), &perfcounters.x[0])
#define perfc_addc(x,y) atomic_add((y), &perfcounters.x[smp_processor_id()])
-#define perfc_adda(x,y,z) atomic_add((z), &perfcounters.x[y])
+#define perfc_adda(x,y,z) \
+ { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
+ atomic_add((z), &perfcounters.x[y]); }
#else /* PERF_COUNTERS */
/* STATUS counters do not reset when 'P' is hit */
PERFSTATUS( shadow_l2_pages, "current # shadow L2 pages" )
PERFSTATUS( shadow_l1_pages, "current # shadow L1 pages" )
+
+#define VMX_PERF_EXIT_REASON_SIZE 37
+#define VMX_PERF_VECTOR_SIZE 0x20
+PERFCOUNTER_ARRAY(vmexits, "vmexits", VMX_PERF_EXIT_REASON_SIZE )
+PERFCOUNTER_ARRAY(cause_vector, "cause vector", VMX_PERF_VECTOR_SIZE )